<template>
    <nav-bar>
        <template v-slot:default>个人信息</template>
    </nav-bar>
    <div>
        <br><br>
        <h3>欢迎来到小T书城</h3>
        <br><br>
        <div class="exit">
            <el-button type="info" @click="exit">退出</el-button>
        </div>
    </div>
</template>

<script>
    //import {computed, reactive, toRefs} from "vue";
    import NavBar from "@/components/common/navbar/NavBar";
    import {getCurrentInstance, onMounted, reactive, toRefs,} from "vue";
    import router from "@/router/index";

    const {onUnmounted} = require("vue");

    export default {
        components:{
            NavBar
        },
        setup(){
            const { proxy } =getCurrentInstance()
            let state = reactive({
                name: ''
            })
            onMounted(()=>{
                proxy.mittBus.on('mittFn',(data) =>{
                    state.name = data.name
                })
            })
            onUnmounted(()=>{
                proxy.mittBus.off('mittFn')
            })
            const exit = function (){
                window.sessionStorage.clear()
                router.push('/login')
            }
            return{
               ...toRefs(state),
                exit
            }
        }
    }
</script>
